package com.gcxy.controller;


import com.gcxy.conf.result.R;
import com.gcxy.dto.RanchPageDTO;
import com.gcxy.service.ICityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 基础表-省市区 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-12-25
 */
@RestController
@RequestMapping("/city")
@Api(value = "cityController", tags = "城市管理")
public class CityController {

    @Autowired
    private ICityService cityService;

    @ApiOperation("获取城市列表")
    @PostMapping("/getAllList")
    public R getAllList() {
        return cityService.getAllList();
    }

    @ApiOperation("获取省列表")
    @PostMapping("/getProvinceList")
    public R getProvinceList() {
        return cityService.getProvinceList();
    }

    @ApiOperation("获取市列表")
    @PostMapping("/getCityList/{id}")
    public R getCityList(@PathVariable String id) {
        return cityService.getCityList(id);
    }

    @ApiOperation("获取区列表")
    @PostMapping("/getDistrictList/{id}")
    public R getDistrictList(@PathVariable String id) {
        return cityService.getDistrictList(id);
    }

    @ApiOperation("获级级联图列表")
    @PostMapping("/getCascadeList")
    public R getCascadeList() {
        return cityService.getCascadeList();
    }

    @ApiOperation("根据名称获取城市数据")
    @GetMapping("/getIdByName")
    public R getIdByName(@RequestParam String name) {
        return cityService.getIdByName(name);
    }
}
